package dev.alm.ollamademo.controller;

import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("chat")
public class ChatController {

    private final ChatModel ollamaChatModel;

    public ChatController(ChatModel chatModel) {
        this.ollamaChatModel = chatModel;
    }

    @GetMapping("simple")
    public String simple() {
        String text = ollamaChatModel.call(new Prompt("你好啊，你是谁？")).getResult().getOutput().getText();
        return text;
    }

}
